Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the provider attribute before hostname/ipaddress in EMS factory #20031

Merged
merged 1 commit into from
Mar 31, 2020

Conversation

skateman
Copy link
Member

@skateman skateman commented Mar 31, 2020

I have a failing spec because the hostname and ipaddress fields can't be set in an ems factory. This is because these methods are basically delegated to the provider which is not yet associated to the EMS when these two attributes are being set.

I found out that the order of these attributes is important, if the first mention of provider preceeds the sequences, it will be also assigned sooner. So if I assign nil to the provider attribute before setting hostname or ipaddress, the provider overridden in child factories will maintain the order of the assignments.

Parent issues:
#18818
#19992

@skateman skateman force-pushed the provider-factories branch from 4a9e1f9 to d78ddfa Compare March 31, 2020 11:03
@miq-bot miq-bot added the wip label Mar 31, 2020
@skateman skateman force-pushed the provider-factories branch from d78ddfa to a2cf7f2 Compare March 31, 2020 12:12
@skateman skateman changed the title [WIP] Adjust EMS factories for the Configuration Management Provider Build the provider conditionally for EMSes using a trait Mar 31, 2020
@miq-bot miq-bot removed the wip label Mar 31, 2020
@skateman skateman force-pushed the provider-factories branch from a2cf7f2 to ca3e508 Compare March 31, 2020 13:12
@skateman skateman changed the title Build the provider conditionally for EMSes using a trait Set the provider attribute before hostname/ipaddress in EMS factory Mar 31, 2020
@skateman
Copy link
Member Author

@miq-bot assign @agrare

@miq-bot
Copy link
Member

miq-bot commented Mar 31, 2020

Checked commit skateman@ca3e508 with ruby 2.5.7, rubocop 0.69.0, haml-lint 0.28.0, and yamllint
1 file checked, 0 offenses detected
Everything looks fine. 🍰

@agrare agrare merged commit d20bbb4 into ManageIQ:master Mar 31, 2020
@skateman skateman deleted the provider-factories branch March 31, 2020 13:44
NickLaMuro added a commit to NickLaMuro/manageiq that referenced this pull request Nov 6, 2020
TRY TO MERGE TO MASTER!!!!

This fix takes a page from a PR from David:

ManageIQ#20031

Which was that instead of trying to assign the provider prior to making
the EMS in the factories, default a provider object type as part of the
`ext_management_system` child definition, and reference it in the
`let(:provider)`.

This is not a problem in Rails 5.2, but does lead to the following error
in Rails 6.0

  5) ServiceTemplateAnsiblePlaybook.create_catalog_item creates and returns a catalog item

     Failure/Error: factory_exists?(factory) ? super : class_from_symbol(factory).create!(*args)

     ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection:

       Cannot modify association 'ManageIQ::Providers::EmbeddedAnsible::Provider#endpoints' because the source reflection class 'Endpoint' is associated to 'ExtManagementSystem' via :has_many.

     # ./spec/support/missing_factory_helper.rb:10:in `create'
     # ./spec/models/service_template_ansible_playbook_spec.rb:11:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:15:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:40:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:47:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:82:in `block (3 levels) in <top (required)>'

Most likely do to a fix that I was unable to track down, but the
following `git log command` is most likely to contain some of the
commits with the fix:

  $ git log --oneline -E --grep "has.*many.*through" 5-2-stable..6-0-stable
NickLaMuro added a commit to NickLaMuro/manageiq that referenced this pull request Nov 6, 2020
TRY TO MERGE TO MASTER!!!!

This fix takes a page from a PR from David:

ManageIQ#20031

Which was that instead of trying to assign the provider prior to making
the EMS in the factories, default a provider object type as part of the
`ext_management_system` child definition, and reference it in the
`let(:provider)`.

This is not a problem in Rails 5.2, but does lead to the following error
in Rails 6.0

  5) ServiceTemplateAnsiblePlaybook.create_catalog_item creates and returns a catalog item

     Failure/Error: factory_exists?(factory) ? super : class_from_symbol(factory).create!(*args)

     ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection:

       Cannot modify association 'ManageIQ::Providers::EmbeddedAnsible::Provider#endpoints' because the source reflection class 'Endpoint' is associated to 'ExtManagementSystem' via :has_many.

     # ./spec/support/missing_factory_helper.rb:10:in `create'
     # ./spec/models/service_template_ansible_playbook_spec.rb:11:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:15:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:40:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:47:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:82:in `block (3 levels) in <top (required)>'

Most likely do to a fix that I was unable to track down, but the
following `git log command` is most likely to contain some of the
commits with the fix:

  $ git log --oneline -E --grep "has.*many.*through" 5-2-stable..6-0-stable
NickLaMuro added a commit to NickLaMuro/manageiq that referenced this pull request Nov 6, 2020
TRY TO MERGE TO MASTER!!!!

This fix takes a page from a PR from David:

ManageIQ#20031

Which was that instead of trying to assign the provider prior to making
the EMS in the factories, default a provider object type as part of the
`ext_management_system` child definition, and reference it in the
`let(:provider)`.

This is not a problem in Rails 5.2, but does lead to the following error
in Rails 6.0

  5) ServiceTemplateAnsiblePlaybook.create_catalog_item creates and returns a catalog item

     Failure/Error: factory_exists?(factory) ? super : class_from_symbol(factory).create!(*args)

     ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection:

       Cannot modify association 'ManageIQ::Providers::EmbeddedAnsible::Provider#endpoints' because the source reflection class 'Endpoint' is associated to 'ExtManagementSystem' via :has_many.

     # ./spec/support/missing_factory_helper.rb:10:in `create'
     # ./spec/models/service_template_ansible_playbook_spec.rb:11:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:15:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:40:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:47:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:82:in `block (3 levels) in <top (required)>'

Most likely do to a fix that I was unable to track down, but the
following `git log command` is most likely to contain some of the
commits with the fix:

  $ git log --oneline -E --grep "has.*many.*through" 5-2-stable..6-0-stable
NickLaMuro added a commit to NickLaMuro/manageiq that referenced this pull request Nov 6, 2020
TRY TO MERGE TO MASTER!!!!

This fix takes a page from a PR from David:

ManageIQ#20031

Which was that instead of trying to assign the provider prior to making
the EMS in the factories, default a provider object type as part of the
`ext_management_system` child definition, and reference it in the
`let(:provider)`.

This is not a problem in Rails 5.2, but does lead to the following error
in Rails 6.0

  5) ServiceTemplateAnsiblePlaybook.create_catalog_item creates and returns a catalog item

     Failure/Error: factory_exists?(factory) ? super : class_from_symbol(factory).create!(*args)

     ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection:

       Cannot modify association 'ManageIQ::Providers::EmbeddedAnsible::Provider#endpoints' because the source reflection class 'Endpoint' is associated to 'ExtManagementSystem' via :has_many.

     # ./spec/support/missing_factory_helper.rb:10:in `create'
     # ./spec/models/service_template_ansible_playbook_spec.rb:11:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:15:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:40:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:47:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:82:in `block (3 levels) in <top (required)>'

Most likely do to a fix that I was unable to track down, but the
following `git log command` is most likely to contain some of the
commits with the fix:

  $ git log --oneline -E --grep "has.*many.*through" 5-2-stable..6-0-stable
NickLaMuro added a commit to NickLaMuro/manageiq that referenced this pull request Nov 10, 2020
TRY TO MERGE TO MASTER!!!!

This fix takes a page from a PR from David:

ManageIQ#20031

Which was that instead of trying to assign the provider prior to making
the EMS in the factories, default a provider object type as part of the
`ext_management_system` child definition, and reference it in the
`let(:provider)`.

This is not a problem in Rails 5.2, but does lead to the following error
in Rails 6.0

  5) ServiceTemplateAnsiblePlaybook.create_catalog_item creates and returns a catalog item

     Failure/Error: factory_exists?(factory) ? super : class_from_symbol(factory).create!(*args)

     ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection:

       Cannot modify association 'ManageIQ::Providers::EmbeddedAnsible::Provider#endpoints' because the source reflection class 'Endpoint' is associated to 'ExtManagementSystem' via :has_many.

     # ./spec/support/missing_factory_helper.rb:10:in `create'
     # ./spec/models/service_template_ansible_playbook_spec.rb:11:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:15:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:40:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:47:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:82:in `block (3 levels) in <top (required)>'

Most likely do to a fix that I was unable to track down, but the
following `git log command` is most likely to contain some of the
commits with the fix:

  $ git log --oneline -E --grep "has.*many.*through" 5-2-stable..6-0-stable
NickLaMuro added a commit to NickLaMuro/manageiq that referenced this pull request Nov 10, 2020
…lets

This fix takes a page from a PR from David:

ManageIQ#20031

Which was that instead of trying to assign the provider prior to making
the EMS in the factories, default a provider object type as part of the
`ext_management_system` child definition, and reference it in the
`let(:provider)`.

This is not a problem in Rails 5.2, but does lead to the following error
in Rails 6.0

  5) ServiceTemplateAnsiblePlaybook.create_catalog_item creates and returns a catalog item

     Failure/Error: factory_exists?(factory) ? super : class_from_symbol(factory).create!(*args)

     ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection:

       Cannot modify association 'ManageIQ::Providers::EmbeddedAnsible::Provider#endpoints' because the source reflection class 'Endpoint' is associated to 'ExtManagementSystem' via :has_many.

     # ./spec/support/missing_factory_helper.rb:10:in `create'
     # ./spec/models/service_template_ansible_playbook_spec.rb:11:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:15:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:40:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:47:in `block (2 levels) in <top (required)>'
     # ./spec/models/service_template_ansible_playbook_spec.rb:82:in `block (3 levels) in <top (required)>'

Most likely do to a fix that I was unable to track down, but the
following `git log command` is most likely to contain some of the
commits with the fix:

  $ git log --oneline -E --grep "has.*many.*through" 5-2-stable..6-0-stable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants